package D1112;

public class Demo02 {
    public static void main(String[] args) {
        work(new Teacher());//匿名对象
        work(new Student());
        work(new Person() {//匿名内部类
            @Override
            public void say() {
                System.out.println("我每天扫地，擦桌子");
            }
        });
    }
    public static void work(Person p){
        //输出教师讲课 提问问题 学生回答问题  玩游戏
        if(p instanceof Teacher){
            ((Teacher) p).Teach();
            p.say();
        }else if(p instanceof Student){
            p.say();
            ((Student) p).playGame();
        }else{
            p.say();
        }





    }
}
